package com.bw.zhuangao5___day002.Fragment.Home.Fragment2;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bw.zhuangao5___day002.R;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * create by ertu
 * create on 2021/9/22
 * description
 */
public class BaseTwoAdpter  extends BaseMultiItemQuickAdapter<JavaMain.ResBean.AvatarBean, BaseViewHolder> {
    public BaseTwoAdpter(@Nullable List<JavaMain.ResBean.AvatarBean> data) {
        super(data);
        addItemType(1, R.layout.homefragment2xml1);
        addItemType(2,R.layout.homefragment2xml2);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, JavaMain.ResBean.AvatarBean avatarBean) {
        switch (avatarBean.getItemType())
        {
            case 1:
                Glide.with(getContext()).load(avatarBean.getThumb())
//                        .placeholder(R.mipmap.shaozi1)//还没有发起网络请求,一般空白或者公司logo
//                        .error(R.mipmap.shaozi2)//发起请求失败，一般撕裂
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭磁盘
                        .skipMemoryCache(true)//关闭内存
                        .transform(new CenterCrop())//居中裁剪
                        .into((ImageView) baseViewHolder.getView(R.id.mig));
                baseViewHolder.setText(R.id.textg,"姓名:"+avatarBean.getUser().getName()+"类型:"+avatarBean.getTag().get(0));
                break;
            case 2:
                Glide.with(getContext()).load(avatarBean.getThumb())
//                        .placeholder(R.mipmap.shaozi1)//还没有发起网络请求,一般空白或者公司logo
//                        .error(R.mipmap.shaozi2)//发起请求失败，一般撕裂
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭磁盘
                        .skipMemoryCache(true)//关闭内存
                        .transform(new CenterCrop(),new RoundedCorners(100))//圆角裁剪
                        .into((ImageView) baseViewHolder.getView(R.id.mig2));
                baseViewHolder.setText(R.id.textg2,"姓名:"+avatarBean.getUser().getName()+"ID:"+avatarBean.getAtime());
                break;

        }
    }





}
